package org.csu.jpetstore_cms.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.csu.jpetstore_cms.pojo.Account;
import org.csu.jpetstore_cms.pojo.Category;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Select("select * from category")
    List<Category> getall();
    @Insert("insert into category(catid,name,descn) values (#{catid},#{name},#{descn})")
    void CreatCategory(Category category);

    @Delete("DELETE FROM item WHERE productid IN (SELECT productid FROM product WHERE category = #{categoryId})")
    void deleteItemsByCategory( String categoryId);

    @Delete("DELETE FROM product WHERE category = #{categoryId}")
    void deleteProductsByCategory( String categoryId);

    @Delete("DELETE FROM category WHERE catid = #{categoryId}")
    void deleteCategoryById( String categoryId);

    void UpdateCategory(Category category);

//    //JWT测试
//    @Select("select * from signon where username = #{username} and password = #{password}")
//    Account login(Account account);
}
